import request from '@/config/axios'

//获取文件管理树-
export const getFileTree = (params) => {
  return request.get({
    url: '/amp/file-manage/tree',
    params
  })
}

//获取文件管理树-只含文件组
export const getFileGroupTree = (params) => {
  return request.get({
    url: '/amp/file-manage/group-tree',
    params
  })
}

// 新增文件
export const createFileManage = (data) => {
  return request.post({ url: '/amp/file-manage/create', data: data, timeout: 30 * 60 * 1000 })
}

// 删除文件
export const deleteFile = (id: number | string) => {
  return request.delete({ url: '/amp/file-manage/delete?id=' + id })
}

// 批量删除文件
export const multiDeleteFile = (ids: (number | string)[]) => {
  return request.delete({
    url: '/amp/file-manage/delete-multi',
    params: {
      ids: ids.join(',')
    }
  })
}

// 批量编辑
export const multiUpdateFile = (params) => {
  return request.put({ url: '/amp/file-manage/update-multi', data: params })
}

// 获取加密文件
export const getFileById = async (params) => {
  return await request.download({
    url: '/amp/file-manage/get-secret-file-by-id',
    params
  })
}

//同步文件
export const createFromAsset = (data) => {
  return request.post({
    url: '/amp/file-manage/create-from-asset',
    data: data,
    timeout: 30 * 60 * 1000
  })
}

// 获取文件信息
export const getFileInfo = async (params) => {
  return await request.getOriginal({
    url: '/amp/file-manage/get',
    params
  })
}

// 获取文件后缀名校验结果
export const checkSuffix = () => {
  return request.get({
    url: '/amp/file-manage/checkSuffix'
  })
}
